--- a/configure.ac
+++ b/configure.ac
@@ -2263,7 +2263,12 @@ AC_SUBST(OUR_DISABLED_INSTALL_MODS)
 AC_SUBST(OUR_DISABLED_UNINSTALL_MODS)
 AC_SUBST(AM_MAKEFLAGS)
 
-ac_configure_args="$ac_configure_args --with-modinstdir=${modulesdir} CONFIGURE_CFLAGS='$CFLAGS $CPPFLAGS' CONFIGURE_CXXFLAGS='$CXXFLAGS $CPPFLAGS' CONFIGURE_LDFLAGS='$LDFLAGS' "
+APR_ADDTO(CONFIGURE_CFLAGS, [$CFLAGS])
+APR_ADDTO(CONFIGURE_CPPFLAGS, [$CPPFLAGS])
+APR_ADDTO(CONFIGURE_CXXFLAGS, [$CXXFLAGS])
+APR_ADDTO(CONFIGURE_LDFLAGS, [$LDFLAGS])
+
+ac_configure_args="$ac_configure_args --with-modinstdir=${modulesdir} CONFIGURE_CFLAGS='$CONFIGURE_CFLAGS' CONFIGURE_CPPFLAGS='$CONFIGURE_CPPFLAGS' CONFIGURE_CXXFLAGS='$CONFIGURE_CXXFLAGS' CONFIGURE_LDFLAGS='$CONFIGURE_LDFLAGS' "
 
 #	--prefix='$prefix' --exec_prefix='$exec_prefix' --libdir='$libdir' --libexecdir='$libexecdir' --bindir='$bindir' --sbindir='$sbindir' \
 #	--localstatedir='$localstatedir' --datadir='$datadir'"
--- a/libs/apr-util/configure.ac
+++ b/libs/apr-util/configure.ac
@@ -20,9 +20,10 @@ dnl Generate ./config.nice for reproduci
 dnl 
 APR_CONFIG_NICE(config.nice)
 
-CFLAGS="$CFLAGS $CONFIGURE_CFLAGS"
-CXXFLAGS="$CXXFLAGS $CONFIGURE_CXXFLAGS"
-LDFLAGS="$LDFLAGS $CONFIGURE_LDFLAGS"
+APR_ADDTO(CFLAGS, [$CONFIGURE_CFLAGS])
+APR_ADDTO(CPPFLAGS, [$CONFIGURE_CPPFLAGS])
+APR_ADDTO(CXXFLAGS, [$CONFIGURE_CXXFLAGS])
+APR_ADDTO(LDFLAGS, [$CONFIGURE_LDFLAGS])
 
 dnl # Some initial steps for configuration.  We setup the default directory
 dnl # and which files are to be configured.
--- a/libs/apr/configure.ac
+++ b/libs/apr/configure.ac
@@ -20,9 +20,10 @@ sinclude(build/apr_hints.m4)
 sinclude(build/libtool.m4)
 sinclude(build/ltsugar.m4)
 
-CFLAGS="$CFLAGS $CONFIGURE_CFLAGS"
-CXXFLAGS="$CXXFLAGS $CONFIGURE_CXXFLAGS"
-LDFLAGS="$LDFLAGS $CONFIGURE_LDFLAGS"
+APR_ADDTO(CFLAGS, [$CONFIGURE_CFLAGS])
+APR_ADDTO(CPPFLAGS, [$CONFIGURE_CPPFLAGS])
+APR_ADDTO(CXXFLAGS, [$CONFIGURE_CXXFLAGS])
+APR_ADDTO(LDFLAGS, [$CONFIGURE_LDFLAGS])
 
 dnl Hard-coded inclusion at the tail end of apr_private.h:
 AH_BOTTOM([
--- a/libs/iksemel/configure.ac
+++ b/libs/iksemel/configure.ac
@@ -6,9 +6,12 @@ AC_CONFIG_SRCDIR([configure.ac])
 AM_INIT_AUTOMAKE
 AC_CONFIG_HEADERS(include/config.h)
 
-CFLAGS="$CFLAGS $CONFIGURE_CFLAGS"
-CXXFLAGS="$CXXFLAGS $CONFIGURE_CXXFLAGS"
-LDFLAGS="$LDFLAGS $CONFIGURE_LDFLAGS"
+m4_include(../apr/build/apr_common.m4)
+
+APR_ADDTO(CFLAGS, [$CONFIGURE_CFLAGS])
+APR_ADDTO(CPPFLAGS, [$CONFIGURE_CPPFLAGS])
+APR_ADDTO(CXXFLAGS, [$CONFIGURE_CXXFLAGS])
+APR_ADDTO(LDFLAGS, [$CONFIGURE_LDFLAGS])
 
 AC_CANONICAL_HOST
 
--- a/libs/libdingaling/configure.ac
+++ b/libs/libdingaling/configure.ac
@@ -8,9 +8,12 @@ AM_INIT_AUTOMAKE
 AC_CONFIG_SRCDIR([src])
 AC_CONFIG_HEADERS([src/config.h])
 
-CFLAGS="$CFLAGS $CONFIGURE_CFLAGS"
-CXXFLAGS="$CXXFLAGS $CONFIGURE_CXXFLAGS"
-LDFLAGS="$LDFLAGS $CONFIGURE_LDFLAGS"
+m4_include(../apr/build/apr_common.m4)
+
+APR_ADDTO(CFLAGS, [$CONFIGURE_CFLAGS])
+APR_ADDTO(CPPFLAGS, [$CONFIGURE_CPPFLAGS])
+APR_ADDTO(CXXFLAGS, [$CONFIGURE_CXXFLAGS])
+APR_ADDTO(LDFLAGS, [$CONFIGURE_LDFLAGS])
 
 #Set default language
 AC_LANG_C
--- a/libs/srtp/configure.ac
+++ b/libs/srtp/configure.ac
@@ -3,9 +3,12 @@ AC_INIT(srtp, 2.4.0, mcgrew@cisco.com)
 AC_CONFIG_AUX_DIR(build)
 AM_INIT_AUTOMAKE
 
-CFLAGS="$CFLAGS $CONFIGURE_CFLAGS"
-CXXFLAGS="$CXXFLAGS $CONFIGURE_CXXFLAGS"
-LDFLAGS="$LDFLAGS $CONFIGURE_LDFLAGS"
+m4_include(../apr/build/apr_common.m4)
+
+APR_ADDTO(CFLAGS, [$CONFIGURE_CFLAGS])
+APR_ADDTO(CPPFLAGS, [$CONFIGURE_CPPFLAGS])
+APR_ADDTO(CXXFLAGS, [$CONFIGURE_CXXFLAGS])
+APR_ADDTO(LDFLAGS, [$CONFIGURE_LDFLAGS])
 
 #Set default language
 AC_LANG_C
